/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Classes;

/**
 *
 * @author ward
 */
public class HelperHtml {

    static public Boolean IsMimeTypeNormal( String currentValue )
    {
        if( currentValue == null || currentValue.length() == 0 )
            return true;
        else
            return currentValue.equalsIgnoreCase("text/html;charset=UTF-8" );
    }
    static public String GetSelectBoxOfMimeTypes( String label, String name, String selectedValue ) 
    {
        // "Output Formats", "requestedMimeType", request.getParameter("requestedMimeType") != null )
        if( selectedValue == null )
            selectedValue = "";

        String [] English  = 
        {
            "Normal",
            "Excel",
            "Word",
            "Rich Text Format",
            "Outlook",
            "Powerpoint"
        };
        String [] Type = 
        {
            "text/html;charset=UTF-8",
            "application/vnd.ms-excel",
            "application/msword",
            "application/rtf",
            "application/vnd.ms-outlook",
            "application/vnd.ms-powerpoint"
        };
                    
        String result = StandardLabel(label);
        
        result +=  "<select name='" + name + "' >";
        for( int index = 0, count = Type.length; index < count; index++ )
        {
            String type = Type[index];
            result += String.format( "<option value='%s' %s>%s</option>",
                    type, 
                    type.equalsIgnoreCase(selectedValue) ? "selected='selected'":"" , 
                    English[ index ] );
        }
        result += "</select>";
        return result;
    }

    static public String StandardLabel( String text )
    {
        String result = String.format("<label >%s</label>", text );
        return result;
    }
    
    static public String GetCheckbox( String label, String name, boolean booleanState ) 
    {
        // "Filter by Value", "byValue", byValue_Value.length() > 0 
        String result = StandardLabel( label );
        
        result +=  String.format( "<input type='checkbox'  "  
                + "name='" + name + "' "
                // + "value='" + label + "' "
                + (booleanState ? "checked" : "") 
                + " />");
        return result;
    }
    
    static public String GetHead()
    {
        String retVal = 
            "<head>" 
            +"<link rel='STYLESHEET' type='text/css' href='images/myStyle.nxa.css' />" 
            +"</head>";
        
        return retVal;
    }
}
